import cv2
import multiprocessing
class Camery:
    def __init__(self,img_queue):
        self.img_queue = img_queue
        # self.camery_process = multiprocessing.Process(target=self.parse_pic)
        # self.camery_process.start()
    def parse_pic(self):
        cap = cv2.VideoCapture(0)
        cap.set(cv2.cv.CV_CAP_PROP_FRAME_WIDTH,640);
        cap.set(cv2.cv.CV_CAP_PROP_FRAME_HEIGHT,320);
        cap.set(cv2.cv.CV_CAP_PROP_FPS,20);
        cal_frame = 0
        frame_err = 0.0
        toal_angle = 0.0
        MAX_FRAME = 10
        last_ave = 0
        # lcopausb = lcopa_usb.LcopaUsb()
        # lcopausb.open(0x1234)
        # mu_phi = load_uphi_data.u_phi("./u-phi/DF2015-FA02.txt")
        # print mu_phi.toString()
        # lcoap = calculate_codev.lcopa_vol(mu_phi)
        # btyes=lcoap.calculate_voltage((0.003))
        # lcopausb.send_byte(btyes)
        # bp = bp_nn.BPNN('','')
        # str_time = time.strftime('%Y-%m-%d-%H-%M-%S',time.localtime(time.time()))
        # fobj=open("./"+str_time+".txt",'w')
        while(True):
            # Capture frame-by-frame
            ret, frame = cap.read()
            self.img_queue.put(frame)
            # cv2.imshow("frame",frame)
            # gray = cv2.cvtColor(frame, cv2.COLOR_RGB2GRAY)